package com.linkoog.devtools.http.request.http_request.request_param;

import com.intellij.ui.Gray;
import com.intellij.ui.JBColor;
import com.intellij.ui.components.JBScrollPane;
import com.intellij.util.ui.JBUI;
import com.linkoog.devtools.intellij.ui.table.ListTableView;
import com.linkoog.devtools.intellij.ui.table.row_data.KeyValWithCheckedTableRowData;
import lombok.Getter;
import java.util.List;

import javax.swing.*;
import java.awt.*;
import java.util.Map;

public class HttpParamPanel extends JBScrollPane{

    @Getter
    private final ListTableView<KeyValWithCheckedTableRowData> paramTable;

    public HttpParamPanel() {
        paramTable = KeyValWithCheckedTableRowData.createListTableView();
        this.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
        this.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
        this.setBorder(JBUI.Borders.customLineTop(new JBColor(Gray._214, new Color(30, 31, 34))));
        this.setViewportView(paramTable);

        paramTable.setBackground(JBColor.WHITE);
    }

    public Map<String, List<String>> getParams() {
        return KeyValWithCheckedTableRowData.getKeyValue(paramTable);
    }

    public void reloadData(Map<String, String> params) {
        KeyValWithCheckedTableRowData.reloadData( paramTable,  params);
    }



}
